<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>分页界面</title>
    <link rel="stylesheet" type="text/css" href="${s.base}/lib/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/index.css"/>
    <link rel="stylesheet" type="text/css" href="${s.base}/css/base/theme/theme.css"/>
</head>
<body>
<div class="wrap-container clearfix">
    <div class="column-content-detail">
        <form class="layui-form">
            <div class="search-cont clearfix" id="tool">
                <div class="operation-btn-cont">
                    <!--button开始-->
                    <button class="layui-btn layui-btn-normal layui-btn-mid" type="button" id="addBtn" style="display: none"><i
                            class="iconfont marr5">&#xe65e;</i>添加
                    </button>
                    <!--button结束-->
                </div>
            </div>
        </form>
        <div class="layui-form" id="table-list">
            <table id="entityList" lay-filter="entityList" class="cy-list-table"></table>
        </div>
    </div>
</div>
<!--操作-->
<script type="text/html" id="entityBar">
    <a class="layui-btn layui-btn-radius layui-btn-primary layui-btn-sm layui-smbtn-green" lay-event="edit">编辑</a>
    <button type="button" class="layui-btn layui-btn-radius layui-btn-primary layui-btn-sm layui-smbtn-red" lay-event="delete">删除</button>
</script>
<script src="${s.base}/lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="${s.base}/js/common.js" type="text/javascript" charset="utf-8"></script>
<script>
    var applyId='${applyId}';
    var tableIns = null;
    layui.use(['jquery', 'table', 'page', 'baseutil'], function () {
        var $ = layui.jquery,
            page = layui.page,
            table = layui.table,
            baseutil = layui.baseutil;

        baseutil.AjaxPostMark('/reward/rewardshop/list', {"applyId":applyId}, function (data) {
            if (data != null && data.length > 0) {
                $('#addBtn').hide();
            } else {
                $('#addBtn').show();
            }
        });

        //获取分页数据
        var url = "/reward/rewardshop/page?applyId="+applyId;
        var cols = [
            {type: 'checkbox', fixed: 'left'},
            {field: 'name', title: '商铺名称', align: 'center'},
            {field: 'password', title: '默认密码', align: 'center'},
            {field: 'limitDescription', title: '限额说明', align: 'center'},
            {field: 'createUserName', title: '创建人', align: 'center'},
            {
                field: 'createTime', title: '创建时间', align: 'center', templet: function (d) {
                    return new Date(d.createTime).Format("yyyy-MM-dd hh:mm:ss");
                }
            },
            {title: '操作', width: 170, templet: '#entityBar', align: "center"}
        ];
        tableIns = page.initDate(cols, url, false);

        //监听行工具事件
        table.on('tool(entityList)', function (obj) {
            var layEvent = obj.event,
                data = obj.data;
            if (layEvent === 'edit') {
                page.editPopup('/reward/rewardshop/getEdit?applyId='+applyId+'&id=' + data.id, '编辑');
            }
            if (layEvent === 'delete') {
                page.delete('/reward/rewardshop/remove', {"id": data.id, "_method": "DELETE"}, "确定删除吗？", function () {
                    location.reload();
                });
            }
        });

        //监听添加按钮事件
        $('#addBtn').bind('click', function () {
            page.editPopup('/reward/rewardshop/getEdit?applyId='+applyId, '添加');
        });
    });
</script>
</body>
</html>